#! /bin/bash
#create user
while true
do
	read -p "please enter prefix & password & num[wangtao 123 5]: " prefix pass num
	printf "user infomation:
	---------------------------
	user prefix: $prefix
	user password: $pass
	user num: $num
	--------------------------
	"
	read -p "are you sure?[y/n]: " action

	if [ "$action" = "y" ];then
		break
	fi 
done

for i in `seq -w $num`
do
	user=$prefix$i
	id $user &>/dev/null
	if [ $? -eq 0 ];then
		echo "user $user 已存在"
	else
		useradd $user
		echo "$pass" |passwd --stdin $user &>/dev/null
		if [ $? -eq 0 ];then
			echo "$user is create"
		fi 
	fi
done
